package com.gton.io;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @description: 通用响应
 * @author: GuoTong
 * @createTime: 2022-12-02 14:12
 * @since JDK 1.8 OR 11
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseLimitResponse<T> extends BasePage {

    /**
     * Description: 当前页数据
     */
    private List<T> responseBody;

    /**
     * Description:  总条数
     */
    private long totalNum;


    /**
     * Description:  总页数
     */
    private long pageCount;


    public static <T> BaseLimitResponse<T> getInstance() {
        return new BaseLimitResponse<>();
    }

    /**
     * Description: 获取响应对象
     *
     * @param responseBody 当前页数据
     * @param totalNum     总数据
     * @param pageCount    总页数
     * @param pageIndex    当前页
     * @param pageSize     每页展示数据大小
     * @author: GuoTong
     * @date: 2022-12-02 15:01:48
     * @return:com.gton.io.BaseLimitResponse<T>
     */
    public static <T> BaseLimitResponse<T> getInstance(List<T> responseBody, long totalNum, long pageCount, long pageIndex, long pageSize) {
        BaseLimitResponse<T> response = new BaseLimitResponse<>();
        response.setResponseBody(responseBody);
        response.setPageCount(pageCount);
        response.setTotalNum(totalNum);
        response.setPageSize(pageSize);
        response.setPageIndex(pageIndex);
        return response;
    }
}
